//
//  ViewController.m
//  IOS
//
//  Created by blue on 15-11-5.
//  Copyright (c) 2015年 HYD. All rights reserved.
//

#import "ViewController.h"
//#import "QuartzCore.framework"
@interface ViewController ()
{
    UILabel * l;

}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    self.view.backgroundColor = [UIColor greenColor];
    l = [UILabel new];
    l.text =@"你好，世界！";
    [l sizeToFit];
    l.center = CGPointMake (self.view.frame.size.width/2.0,self.view.frame.size.height/2.0);
    l.textColor = [UIColor redColor];
    [self.view addSubview:l];
    
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame = CGRectMake(100, 100, 200, 44);
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
    }

-(void)onClick: (id)sender{
    
    UIView * line =[[UIView alloc]initWithFrame:CGRectMake(0, 200, 0, 3)];
    line.backgroundColor = [UIColor brownColor];
    line.clipsToBounds=YES;
     [self.view addSubview:line];
    

    [UIView animateWithDuration:1.6 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/2.0,44);
    
    
    }];

}


-(void )viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:1.6 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/6.0, self.view.frame.size.height - 200 );
    }];
    

}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
